package com.ybfenpan.job;


import com.ybfenpan.utils.Backup;
import com.ybfenpan.utils.Param;
import org.springframework.scheduling.annotation.Scheduled;

import java.text.SimpleDateFormat;
import java.util.Date;


public class BackupJob {
	 
	
	//@Scheduled(cron = "0 */10 * * * ?")  十分钟一次 
	//一个小时一次
	@Scheduled(cron = "0 0 */2 * * ?")
	void bakcupCount() throws Exception{   
		
		if(Param.backup){
			Param.backup=false;
			//备份时名称
			SimpleDateFormat formatter2 = new SimpleDateFormat("yyyyMMddHHmm"); 
			String fileName = "com.ybfenpan("+formatter2.format(new Date())+")";
		
	        Backup backup=new Backup("root","123456xxxx","com.ybfenpan",null,"utf8","d:\\backup\\"+fileName+".sql");
	        boolean result=backup.backup_run();
	        if(result)
	            System.out.println("备份成功");   
		 
			Param.backup=true;
		}
		 	   
    }
	  

 
}
